<!--
Copyright 2003 Cordys R&D B.V. 

This file is part of the Cordys SAP Connector. 

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- 
 Project  : Cordys BAC
 File Name : KeyStoreDetails.htm
 Description : This UI is to create new key store.
-->

<html xmlns:eibus >
<head>
	<title>Key Store</title>
	<link REL="stylesheet" href="/cordys/wcp/style/behaviors.css"></link>
</head>
<script language="JavaScript">

/*		Function which checks whether the path typed is correct or not
		@outParam boolean <true> if correct
					else <false>
*/

var ErrorOccured;
function lookForValidPath()
{
	var regExp = /[\?:<>\*"|\/]/g
	var collectionMatch = keystorePath.value.match(regExp);

	if ( collectionMatch && collectionMatch.length >=0 )
	{
		return true;
	}

	if (keystorePath.value.indexOf("..")>=0 || keystorePath.value.indexOf(":\\")>=0 || keystorePath.value.indexOf(":")>=0)
	{
		return true;
	}
	return false;
}
/*		Function which checks the validations for all the fields and displays
		the appropriate Error message
*/
function checkAll()
{
	//checks the type field
	if (type.value==0)
	{
		window.alert("Please Select one type!");
		type.focus();
		return false;
	}
	//checks the Provider Name field
	if (provider.value==0)
	{
		window.alert("Please Select one Provider Name!");
		provider.focus();
		return false;
	}
	//checks the path field
	if(!lookForValidPath())
	{
		window.alert("Please enter Valid Path!");
		keystorePath.focus();
		keystorePath.select();
		return false;
	}
	//checks the password field
	if (passwd.value=="")
	{
		window.alert("Please enter Password!");
		passwd.focus();
		passwd.select();
		return false;
	}
	return true;
}
function createKeyStore()
{
	if (checkAll())
	{
		/*Code should be added which creates the keystore*/
		CreateKeyStoreXML.selectSingleNode("SOAP:Envelope/SOAP:Body/createKeyStore/type").text = type.value;
		CreateKeyStoreXML.selectSingleNode("SOAP:Envelope/SOAP:Body/createKeyStore/provider").text =provider.value;
		CreateKeyStoreXML.selectSingleNode("SOAP:Envelope/SOAP:Body/createKeyStore/keystorePath").text = keystorePath.value;
	    CreateKeyStoreXML.selectSingleNode("SOAP:Envelope/SOAP:Body/createKeyStore/passwd").text = passwd.value;
		ErrorOccured=0;
		dicreateKeyStore.reset();		
	}
}
function alertError(dataChangeEvent)
{	
	ErrorOccured=1;
	alertMesasge();
}
function alertMesasge()
{	
	if(ErrorOccured==0)
		alert("KeyStore Created.");
}
</script>
<eibus:dataisland
	id="dicreateKeyStore"
	request="CreateKeyStoreXML.XMLDocument"
	automatic = "false"
	onsoapfault="alertError()"
	ondatacompleted="alertMesasge()"
	async="false"

>
</eibus:dataisland>
<xml id="CreateKeyStoreXML">
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP:Body>
        <createKeyStore xmlns="http://schemas.cordys.com/1.0/keyStore">
			<type></type>
	        <provider></provider>
	        <keystorePath></keystorePath>
	        <passwd></passwd>
        </createKeyStore>
    </SOAP:Body>
</SOAP:Envelope>
</xml>
<body>	
		<table  align="center">
		<tr>
			   <td>
					<label><b>Enter details for KeyStore</b></label>
			   </td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr >
			<td>Type</td>
		</tr>
		<tr >
			<td >
				<input id="type" class="input"  type="text" value="JKS" readonly>
				
			</td>
		</tr>
		<tr>
		    <td>&nbsp;</td>
		</tr>
		<tr >
			<td>Provider Name</td>
		</tr>
		<tr >
			<td>
			
				<input id="provider" class="input"  type="text" value="SUN" readonly>
			</td>
		</tr>
		<tr>
		    <td>&nbsp;</td>
		</tr>
		<tr >
			<td>KeyStore Path</td>

		</tr>
		<tr >
			<td>
				<input type="text" id="keystorePath" size="28" class="input"></input>
			</td>
		</tr>
		<tr>
		    <td>&nbsp;</td>
		</tr>
		<tr>
			<td>KeyStore Password</td>
		</tr>
		<tr>
			<td>
				<input id="passwd" type="password" size="28" class="input"></input>
			</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>
				<input type="button" class="medium"  value="Create KeyStore" onclick='createKeyStore()'; class="dark">
			</td>
		</tr>	
	</table>	
</body>
</html>
